package com.woniuxy.qiantai.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.qiantai.entity.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author woniumrwang
 * @since 2023-01-06 02:44:35
 */
@Mapper
public interface BookMapper extends BaseMapper<Book> {

    //更新库存量
    @Update("update t_book set storecount=storecount-#{itemNum} where id=#{bookId} and storecount >= #{itemNum}")
    int updateBookStoreCount(Long bookId,Integer itemNum);

    //更新购买量
    @Update("update t_book set buycount=buycount+#{itemNum} where id=#{bookId}")
    int updateBuyCount(Long bookId,Integer itemNum);

}
